import sys
from PyQt5.QtWidgets import QApplication, QFileDialog, QMainWindow, QMessageBox

import bmp2c_ui
import bmp2c


class MyWindow(QMainWindow, bmp2c_ui.Ui_mainWindow):
    __image_flie = ''

    def __init__(self, parent=None):
        super(MyWindow,self).__init__(parent=parent)
        self.setupUi(self)
        self.pushButton_openfile.clicked.connect(self.menu_open_file)
        self.pushButton_convert.clicked.connect(self.image2c)

    def menu_open_file(self):
        self.__image_flie = QFileDialog.getOpenFileNames(self,"选取文件",'','Excel files(*.*)')                               #起始路径
                  
    def image2c(self):
        for i in range( len(self.__image_flie[0])):
            file_path = str(self.__image_flie[0][i])
            if bmp2c.bmp2c(file_path) == 0:
                QMessageBox.question(self, "提问对话框", "convert error", QMessageBox.Yes | QMessageBox.No)                             
        
        QMessageBox.question(self, "提问对话框", "转换完成 ", QMessageBox.Yes | QMessageBox.No)                             
        


if __name__ == '__main__':
    app = QApplication(sys.argv)
    myWin = MyWindow()
    myWin.show()
    sys.exit(app.exec_())


